home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
OLE2BOOK.ZIP
/
CHAP08.ZIP
/
CHAP08
/
PATRON
/
PAGES.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-07
|
13KB
|
391 lines
/*
* PAGES.H
* Modifications for Chapter 8
*
* Definitions and function prototypes for the Pages window control
* as well as the CPage and CTenant classes.
*
* Copyright (c)1993 Microsoft Corporation, All Rights Reserved
*
* Kraig Brockschmidt, Software Design Engineer
* Microsoft Systems Developer Relations
*
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _PAGES_H_
#define _PAGES_H_
//We need this for UICursorLoad and new-style cursors.
#include <bttncur.h>
//Versioning.
#define VERSIONMAJOR 2
#define VERSIONMINOR 0
#define VERSIONCURRENT 0x00020000
//Classname
#define SZCLASSPAGES "pages"
#define HIMETRIC_PER_INCH 2540
#define LOMETRIC_PER_INCH 254
#define LOMETRIC_BORDER 60 //Border around page
//Window extra bytes and offsets
#define CBPAGESWNDEXTRA (sizeof(LONG))
#define PAGEWL_STRUCTURE 0
/*
* Tenant class describing an individual piece of data in a page.
* It knows where it sits, what object is inside of it, and what
* its idenitifer is such that it can find it's storage within a page.
*/
//Patron Objects clipboard format
typedef struct tagPATRONOBJECT
{
POINTL ptl; //Location of object
POINTL ptlPick; //Pick point from drag-drop operation.
SIZEL szl; //Extents of object (absolute)
FORMATETC fe; //Actual object format.
} PATRONOBJECT, FAR * LPPATRONOBJECT;
//Values for hit-testing, drawing, and resize-tracking tenants
#define CXYHANDLE 5
//Tenant creation types (not persistent)
typedef enum
{
TENANTTYPE_NULL=0,
TENANTTYPE_STATIC,
} TENANTTYPE, FAR * LPTENANTTYPE;
//State flags
#define TENANTSTATE_DEFAULT 0x00000000
#define TENANTSTATE_SELECTED 0x00000001
class __far CTenant
{
private:
HWND m_hWnd; //Pages window, same as CPages.
DWORD m_dwID; //Persistent DWORD identifier
DWORD m_cOpens; //Count calls to FOpen.
BOOL m_fInitialized; //Something here?
LPUNKNOWN m_pObj; //The object that lives here.
LPSTORAGE m_pIStorage; //Sub-storage for this tenant
FORMATETC m_fe; //As used to create the object.
DWORD m_dwState; //State flags
RECTL m_rcl; //Space of this object.
class CPages FAR *m_pPG; //Pages window
protected:
HRESULT CreateStatic(LPDATAOBJECT, LPFORMATETC, LPUNKNOWN FAR *);
public:
CTenant(DWORD, HWND, CPages FAR *);
~CTenant(void);
DWORD GetID(void);
UINT GetStorageName(LPSTR);
UINT UCreate(TENANTTYPE, LPVOID, LPFORMATETC, LPPOINTL
, LPSIZEL, LPSTORAGE, LPPATRONOBJECT, DWORD);
BOOL FLoad(LPSTORAGE, LPFORMATETC, LPRECTL);
BOOL FOpen(LPSTORAGE);
void Close(BOOL);
BOOL Update(void);
void Destroy(LPSTORAGE);
void Select(BOOL);
BOOL Activate(DWORD);
void Draw(HDC, DVTARGETDEVICE FAR *, HDC, int, int, BOOL, BOOL);
void Repaint(void);
void Invalidate(void);
void ObjectGet(LPUNKNOWN FAR *);
void FormatEtcGet(LPFORMATETC, BOOL);
void SizeGet(LPSIZEL, BOOL);
void SizeSet(LPSIZEL, BOOL);
void RectGet(LPRECTL, BOOL);
void RectSet(LPRECTL, BOOL);
};
typedef CTenant FAR * LPTENANT;
//Return codes for UCreate
#define UCREATE_FAILED 0
#define UCREATE_GRAPHICONLY 1
#define UCREATE_PLACEDOBJECT 2
typedef struct __far tagTENANTLIST
{
DWORD cTenants;
DWORD dwIDNext;
} TENANTLIST, FAR *LPTENANTLIST;
/*
* Persistent information we need to save for each tenant, which is done
* in the tenant list instead of with each tenant. Since this is a small
* structure it's best not to blow another stream for it (overhead).
*/
typedef struct tagTENANTINFO
{
DWORD dwID;
RECTL rcl;
FORMATETC fe; //Excludes ptd
} TENANTINFO, FAR *LPTENANTINFO;
#define SZSTREAMTENANTLIST "Tenant List"
/*
* Page class describing an individual page and what things it contains,
* managing an IStorage for us.
*
* A DWORD is used to identify this page as the name of the storage
* is the string form of this ID. If we added a page every second,
* it would take 136 years to overrun this counter, so we can
* get away with saving it persistently. I hope this software is
* obsolete by then.
*/
class __far CPage
{
private:
HWND m_hWnd; //Pages window, same as CPages.
DWORD m_dwID; //Persistent DWORD identifier
LPSTORAGE m_pIStorage; //Sub-storage for this page.
DWORD m_cOpens; //Calls to FOpen.
class CPages FAR *m_pPG; //Pages window
DWORD m_dwIDNext;
DWORD m_cTenants;
HWND m_hWndTenantList; //Listbox that manages our tenant list
UINT m_iTenantCur;
LPTENANT m_pTenantCur;
UINT m_uHTCode; //Last hit-test on mouse move.
UINT m_uSizingFlags; //Restrictions on sizing motion.
BOOL m_fTracking; //Tracking resize?
RECTL m_rclOrg; //Original before tracking
RECTL m_rcl; //Tracking rectangle.
RECTL m_rclBounds; //Boundaries for size tracking.
HDC m_hDC; //Tracking hDC.
protected:
BOOL FTenantGet(UINT, LPTENANT FAR *, BOOL);
BOOL FTenantAdd(UINT, DWORD, LPTENANT FAR *);
LPDATAOBJECT TransferObjectCreate(LPPOINTL);
//PAGEMOUS.CPP
UINT TenantFromPoint(UINT, UINT, LPTENANT FAR *);
//CHAPTER8MOD
BOOL DragDrop(UINT, UINT, UINT);
//End CHAPTER8MOD
public:
CPage(DWORD, HWND, class CPages FAR *);
~CPage(void);
DWORD GetID(void);
BOOL FOpen(LPSTORAGE);
void Close(BOOL);
BOOL Update(void);
void Destroy(LPSTORAGE);
UINT GetStorageName(LPSTR);
void Draw(HDC, int, int, BOOL, BOOL);
BOOL TenantCreate(TENANTTYPE, LPVOID, LPFORMATETC
, LPPATRONOBJECT, DWORD);
BOOL TenantDestroy(void);
BOOL TenantClip(BOOL);
BOOL FQueryObjectSelected(HMENU);
//PAGEMOUSE.CPP
BOOL OnLeftDown(UINT, UINT, UINT);
BOOL OnLeftDoubleClick(UINT, UINT, UINT);
BOOL OnLeftUp(UINT, UINT, UINT);
void OnNCHitTest(UINT, UINT);
BOOL OnSetCursor(UINT);
void OnMouseMove(UINT, int, int);
};
typedef CPage FAR * LPPAGE;
/*
* Structures to save with the document describing the device
* configuration and pages that we have. This is followed by
* a list of DWORD IDs for the individual pages.
*/
typedef struct __far tagDEVICECONFIG
{
DEVMODE dm;
char szDriver[CCHDEVICENAME];
char szDevice[CCHDEVICENAME];
char szPort[CCHDEVICENAME];
} DEVICECONFIG, FAR * LPDEVICECONFIG;
typedef struct __far tagPAGELIST
{
DWORD cPages;
DWORD iPageCur;
DWORD dwIDNext;
} PAGELIST, FAR *LPPAGELIST;
//PAGEWIN.CPP
LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL __export FAR PASCAL AbortProc(HDC, int);
BOOL __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
void